import tensorflow as tf
from tensorflow_core.python.framework import graph_util

v1 = tf.Variable(tf.constant(1.0,shape=[1]),name='V1')
v2 = tf.Variable(tf.constant(2.0,shape=[1]),name='V2')

reslut = tf.add(v1,v2,name='add_op')

init = tf.global_variables_initializer()

with tf.Session() as sess:
    sess.run(init)

    constant_graph = graph_util.convert_variables_to_constants(sess,sess.graph_def,['add_op'])
    with tf.gfile.FastGFile('./demo2/model.pb',mode='wb') as f:
        f.write(constant_graph.SerializeToString())
